package main

import (
	"github.com/gogf/gf/frame/g"
	"github.com/gogf/gf/net/ghttp"
	"kardou/app/system/rbac"
	"kardou/app/system/sys"
	"kardou/app/system/user"
	_ "kardou/boot"
	_ "kardou/router"
)

func MiddlewareCORS(r *ghttp.Request) {
	r.Response.CORSDefault()
	r.Middleware.Next()
}

func main() {
	s := g.Server()
	//s.Domain("kardou.local")
	//s.SetPort(8100)
	/*s.SetConfigWithMap(g.Map{
		"address":          ":8100",
		//"serverRoot":       "/var/www/Server",
		//"indexFiles":       g.Slice{"index.html", "main.html"},
		"accessLogEnabled": true,
		"errorLogEnabled":  true,
		"pprofEnabled":     true,
		"logPath":          "D:\\project\\go\\kardou\\logs",
		"sessionIdName":    "MySessionId",
		"sessionPath":      "D:\\project\\go\\kardou\\tmp",
		"sessionMaxAge":    24 * time.Hour,
		"dumpRouterMap":    false,

	})*/
	s.Group("/api", func(group *ghttp.RouterGroup) {
		group.Middleware(MiddlewareCORS)
		user.InitRoute(group)
		rbac.InitRoute(group)
		sys.InitRoute(group)
	})

	s.BindHandler("/", func(r *ghttp.Request) {
		r.Response.Write("hello world")
	})

	//用户模块

	s.Run()
}
